<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">

    <title>发表评论</title>

    <link href="__PUBLIC__/AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css">

    <link href="__PUBLIC__/css/personal.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/css/appstyle.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="__PUBLIC__/AmazeUI-2.4.2/assets/css/uploadView.css">
    <script type="text/javascript" src="__PUBLIC__/js/jquery-1.7.2.min.js"></script>
</head>

<body>

<div class="center">
    <div class="col-main">
        <div class="main-wrap">

            <div class="user-comment">
                <!--标题 -->
                <div class="am-cf am-padding">
                    <div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">发表评论</strong> /
                        <small>Make&nbsp;Comments</small>
                    </div>
                </div>
                <hr/>
                <form id="comment_form" method="post" enctype="multipart/form-data">
                <div class="comment-main">
                    <input type="hidden" id="order_id" name="order_id" value="{$goods.order_id}">
                    <input type="hidden" id="order_goods_id" name="goods_id" value="{$goods.goods_id}">
                    <input type="hidden" id="order_rec_id" name="rec_id" value="{$goods.rec_id}">
                    <input type="hidden" id="evaluate" name="evaluate">
                    <div class="comment-list">
                        <div class="item-pic">
                            <a href="#" class="J_MakePoint">
                                <img src="{$goods.image_url}" class="itempic">
                            </a>
                        </div>

                        <div class="item-title">

                            <div class="item-name">
                                <a href="#">
                                    <p class="item-basic-info">{$goods.goods_name}</p>
                                </a>
                            </div>
                            <div class="item-info">
                                <div class="info-little">
                                    <!--<span>颜色：洛阳牡丹</span>-->
                                    <!--<span>包装：裸装</span>-->
                                    <span>{$goods.spec_key_name}</span>
                                </div>
                                <div class="item-price">
                                    价格：<strong>{$goods.goods_price}元</strong>
                                </div>
                            </div>
                        </div>
                        <div class="clear"></div>
                        <div class="item-comment">
                            <textarea placeholder="请写下对宝贝的感受吧，对他人帮助很大哦！" id="comment_content" class="comment-content" name="content"></textarea>
                        </div>
                        <div class="am-form-group" style="margin-top: 5px">
                            <div class="control-group js_uploadBox">
                                <div class="am-u-sm-3 " id="divi" onclick="deleteInput('i')">
                                    <div class="btn-upload">
                                        <a href="javascript:void(0);"><i class="am-icon-picture-o am-icon-md" style="color:rgba(0,0,0,0.4)"></i><span class="js_uploadText" style="font-size:24px"></span></a>
                                        <input id="js_upFile" class="js_upFile" data-order_goods_id="{$goods.rec_id}" type="file" name="cover[]">
                                    </div>
                                    <div class="js_showBox"></div>
                                </div>
                            </div>
                        </div>
                        <div class="item-opinion">
                            <li><i class="op1 comment-item" data-value="0"></i>好评</li>
                            <li><i class="op2 comment-item" data-value="1"></i>中评</li>
                            <li><i class="op3 comment-item" data-value="2"></i>差评</li>
                        </div>
                    </div>

                    <div class="info-btn" style="margin-top: 15px;">
                        <eq name="is_complete" value="1">
                            <div class="am-btn am-btn-danger am-round" onclick="addComment()">提交评论</div>
                            <else/><div class="am-btn am-btn-danger am-round" onclick="addComment()">下一步</div>
                        </eq>
                    </div>

                    <script type="text/javascript">
                        $(document).ready(function () {
                            $(".comment-list .item-opinion li").click(function () {
                                $(this).prevAll().children('i').removeClass("active");
                                $(this).nextAll().children('i').removeClass("active");
                                $(this).children('i').addClass("active");

                            });
                        })
                    </script>


                </div>
                </form>
            </div>

        </div>
        <!--底部-->

    </div>


</div>

</body>

</html>
<script type="text/javascript" src="__PUBLIC__/basic/js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/AmazeUI-2.4.2/assets/js/amazeui.js"></script>
<script type="text/javascript" src="__PUBLIC__/layer/layer.js"></script>
<script src="__PUBLIC__/AmazeUI-2.4.2/assets/js/jquery.uploadView.js"></script>
<script src="__PUBLIC__/AmazeUI-2.4.2/assets/js/jquery.uploadView.add.js"></script>
<script>
    function modalInfo(info,success){
        layer.msg(info);
//        if(success) {
//            layer.msg(info, {icon: 1});
//        }else{
//            layer.msg(info, {icon: 2});
//        }

    }
    function addComment() {
        var order_id = $('#order_id').val();
        var goods_count = $('#goods_count').val();
        var evaluate = $('.comment-list .item-opinion .comment-item.active').data('value');
        console.info(evaluate);
        var content = $('#comment_content').val();
        var rec_id = $('#rec_id').val();
        if(evaluate == '' && evaluate!=0){
            modalInfo('请选择评价类型！',false);
            return;
        }
        if(!content){
            modalInfo('请填写评论内容！',false);
            return;
        }
        $('#evaluate').val(evaluate);
        var formData = new FormData(document.getElementById('comment_form'));
        console.info(formData);
        $.ajax({
            url:"__APP__/Home/Order/publishComment",
            type:"post",
//            data:$('#comment_form').serialize(),
            data:formData,
            dataType: "json",
            processData: false,
            contentType: false,
            success: function(data){
                console.info(data);
//                modalInfo(data.message,data.success);
//                var icon = 2;
//                if(data.success){
//                    icon = 1;
//                }
                layer.msg(data.message,{type:1},function(){
                    if(data.is_complete){
                        window.location.href = '__APP__/Home/Me';
                    }else if(data.success){
                        window.location.href = '__APP__/Home/Order/index?type=4';
                    }
//                    window.location.href = '__APP__/Home/Order/index?type=0';
                });
            },
            error:function (data) {
                layer.msg('服务器繁忙！',{type:1,time:1000},function(){
                    location.reload();
                });
//                modalInfo('服务器繁忙！',false);
            }
        });
    }
</script>